<?php
	
	// get the stitch id
	$stitchid = $_GET['stitchid'];
	
	// connect to the database
	require 'db_init.php';
	
	// retrieve the associated tags from the database
	$query = "SELECT tag FROM tags WHERE stitchid='$stitchid'";
	$result = mysql_query( $query );
	
	if(mysql_num_rows($result)){
		
		// print out the table, with one column per tag
		echo '<table><tr><td><b>Tags:</b></td>';
		
		while( $row = mysql_fetch_array( $result ) )
			echo( '<td><a href="#" onclick="document.getElementById(\'searchstr\').value=\''.addslashes(htmlentities($row['tag'])).'\';document.forms[\'search\'].submit();"><img src="style/tag.png" />&nbsp;'.htmlentities($row['tag'], ENT_QUOTES).'</a></td>' );
		
		echo '</tr></table>';
		
	}
	
	// disconnect from the database
	mysql_close();
	
?>